function *foo() {
    console.log('start');
    
    try {
        const res = yield 'foo';
        console.log('res', res);
    } catch(e) {
        console.log('catch', e);
    }

    yield 'foo2';

    console.log('end');
}

const generator = foo();

const result = generator.next();
console.log('result', result); 

generator.throw(new Error('generator.throw'));

const result2 = generator.next();
console.log('result2', result2); 

const result3 = generator.next();

console.log('result3', result3);
